<html>
    
<head>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
        var start = 0;
        var end = 0;
        var binfile = '';
        
        function TestDownload() {
            start = new Date().getTime();
            
            $.ajax({
                type: "GET",
                url: "bigfile.bin?id=" + start,
                dataType: 'application/octet-stream',
                success: function(msg) {
                    binfile = msg;
                    end = new Date().getTime();
                    diff = (end - start) / 1000;
                    bytes = msg.length;
                    speed = (bytes / diff) / 1024 / 1024 * 8;
                    speed = Math.round(speed*100)/100;
                    $('#dlspeed').html('<b>' + speed + ' Mb/s (You)</b>');
                    $('#dlbar').css('width', Math.floor(speed * 30)+'px');
                },
                complete: function(xhr, textStatus) {
                    TestUpload();
                }
            });
        }
        
        function TestUpload() {
            start = new Date().getTime();
            
            $.ajax({
                type: "POST",
                url: "post.aspx?id=" + start,
                data: binfile,
                dataType: 'application/octet-stream',
                success: function(msg) {
                    end = new Date().getTime();
                    diff = (end - start) / 1000;
                    bytes = binfile.length;
                    speed = (bytes / diff) / 1024 / 1024 * 8;
                    speed = Math.round(speed*100)/100;
                    $('#ulspeed').html('<b>' + speed + ' Mb/s (You)</b>');
                    $('#ulbar').css('width', Math.floor(speed * 60)+'px');
                }    
            });
        }
        
        $(document).ready(function() {
            TestDownload();
        });
    </script>
</head>     

<body>
    <p>
        Download speed:<br>
        <img id="dlbar" src="bar.gif" style="width: 1px; height: 10px;"> <span id="dlspeed"><img src="busy.gif"></span><br>
        <img src="bar.gif" width="300" height="10"> 10 Mb/s
    </p>
    <p>
        Upload speed:<br>
        <img id="ulbar" src="bar.gif" style="width: 1px; height: 10px;"> <span id="ulspeed"><img src="busy.gif"></span><br>
        <img src="bar.gif" width="300" height="10"> 5 Mb/s
    </p>
</body>

</html>